package com.you.place.dal.dao;

import java.util.List;

import com.you.common.ibatis.AbstractDAO;
import com.you.place.dal.dao.dataobject.NoteItemDO;

@SuppressWarnings("unchecked")
public class NoteItemDAO extends AbstractDAO {

    public NoteItemDO find(Long id) {
        return (NoteItemDO) super.getSqlMapClientTemplate().queryForObject("MS-SELECT-NOTE-ITEM-BY-PK", id);
    }

    public List<NoteItemDO> queryByNoteId(Long noteId) {
        return super.getSqlMapClientTemplate().queryForList("MS-SELECT-NOTE-ITEM-BY-NOTE-ID", noteId);
    }

    public Long create(NoteItemDO noteItemDO) {

        return (Long) super.getSqlMapClientTemplate().insert("MS-CREATE-NOTE-ITEM", noteItemDO);
    }

    public Integer update(Long id, String content) {
        NoteItemDO noteItem = new NoteItemDO();
        noteItem.setId(id);
        noteItem.setContent(content);
        return super.getSqlMapClientTemplate().update("MS-UPDATE-NOTE-ITEM-CONTENT", noteItem);
    }

    public int deleteById(Long id) {
        return super.getSqlMapClientTemplate().delete("MS-DELETE-NOTE-ITEM-BY-ID", id);
    }

    public int deleteByNoteId(Long noteId) {
        return super.getSqlMapClientTemplate().delete("MS-DELETE-NOTE-ITEM-BY-NOTE-ID", noteId);
    }
}
